;; core/lambdaC.scm - (c) rohan drape, 2000-2005

;; Alias for case-lambda.

(define-syntax lambdaM
  (syntax-rules ()
    ((_ a ...) (case-lambda a ...))))

;; Variant to generate curried functions.

(define-syntax lambdaC
  (syntax-rules ()
    ((_ (a) x ...) 
     (lambda (a) x ...))
    ((_ (a b) x ...)
     (lambdaM ((a) (lambda (b) x ...))
	      ((a b) x ...)))
    ((_ (a b c) x ...) 
     (lambdaM ((a) (lambdaC (b c) x ...))
	      ((a b) (lambda (c) x ...))
	      ((a b c) x ...)))
    ((_ (a b c d) x ...) 
     (lambdaM ((a) (lambdaC (b c d) x ...))
	      ((a b) (lambdaC (c d) x ...))
	      ((a b c) (lambda (d) x ...))
	      ((a b c d) x ...)))
    ((_ (a b c d e) x ...) 
     (lambdaM ((a) (lambdaC (b c d e) x ...))
	      ((a b) (lambdaC (c d e) x ...))
	      ((a b c) (lambdaC (d e) x ...))
	      ((a b c d) (lambda (e) x ...))
	      ((a b c d e) x ...)))))

(define-syntax defineC
  (syntax-rules ()
    ((_ (name argument ...) expr ...)
     (define name (lambdaC (argument ...) expr ...)))))
